package edu.zju.gis.dbfg.server.service.impl;

import com.github.pagehelper.PageHelper;
import edu.zju.gis.dbfg.common.Page;
import edu.zju.gis.dbfg.common.base.BaseServiceImpl;
import edu.zju.gis.dbfg.server.mapper.MapServiceMapper;
import edu.zju.gis.dbfg.server.model.MapService;
import edu.zju.gis.dbfg.server.service.MapServiceService;
import org.springframework.stereotype.Service;


/**
 * @author Chenyr
 * @date 2019/9/11
 **/
@Service
public class MapServiceServiceImpl extends BaseServiceImpl<MapServiceMapper, MapService, String> implements MapServiceService {
    @Override
    public Page<MapService> getServicesByRole(String userId, Page page) {
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new Page<>(mapper.selectByRole(userId));
    }
    @Override
    public Page<MapService> getServicesByUser(String userId, Page page) {
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new Page<>(mapper.selectByUser(userId));
    }
    @Override
    public Page<MapService> searchServicesByRole(String userId,String query, Page page) {
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new Page<>(mapper.searchServicesByRole(userId,query));
    }
    @Override
    public Page<MapService> searchServicesByUser(String userId,String query, Page page) {
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new Page<>(mapper.searchServicesByUser(userId,query));
    }
    @Override
    public  int delete(String id){
        return mapper.delete(id);
    }
}
